package com.example.service;

import com.example.entity.Booking;
import com.example.mapper.BookingMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 房间可用性服务
 * 提取共享逻辑以避免循环依赖
 */
@Service
public class RoomAvailabilityService {

    @Resource
    private BookingMapper bookingMapper;
    
    /**
     * 检查房间在指定日期范围内是否可用
     */
    public boolean checkRoomAvailability(Long roomId, String checkInDate, String checkOutDate) {
        List<Booking> bookings = bookingMapper.selectByDateRange(roomId, checkInDate, checkOutDate);
        return bookings.isEmpty();
    }
} 